#import <Foundation/Foundation.h>

void AfficheInfoPath()
{
	NSString *path = @"~/";
    NSString *pathHome = [path stringByExpandingTildeInPath];
	NSLog(pathHome);
    
    NSArray *pathComponents = [pathHome pathComponents];
    
    for (NSString *element in pathComponents)
    {
        NSLog(@"element: %@", element);
    }
}

void AfficheInfoProcessus()
{
	NSProcessInfo *processInfo = [NSProcessInfo processInfo];
    NSLog(@"Nom du processus courant: '%@' Process ID: '%d'",[processInfo processName], [processInfo processIdentifier]);	
}
		
void AfficheInfoSignets()
{
    NSURL *uETS = [NSURL URLWithString:@"http://www.etsmtl.ca"];
    NSURL *uPOLY = [NSURL URLWithString:@"http://www.polymtl.ca"];
    NSURL *uLOG = [NSURL URLWithString:@"http://cours.logti.etsmtl.ca/log350/"];
    NSURL *uMTL = [NSURL URLWithString:@"http://ville.montreal.qc.ca"];
    NSURL *uMEL = [NSURL URLWithString:@"http://www.montrealenlumiere.com/"];
    NSURL *uLPE = [NSURL URLWithString:@"http://www.petiteecole.com/"];
	
    NSString *ETS = @"École de technologie supérieure";
    NSString *POLY = @"École polytechnique de Montréal";
    NSString *LOG = @"LOG350";
    NSString *MTL = @"Ville de Montréal";
    NSString *MEL = @"Montréal en lumières";
    NSString *LPE = @"La petite école";   
	
    NSMutableDictionary * UrlDictionnary = [NSMutableDictionary dictionary];
    [UrlDictionnary setObject: uETS forKey:ETS];
    [UrlDictionnary setObject: uPOLY forKey:POLY];
    [UrlDictionnary setObject: uLOG forKey:LOG];
    [UrlDictionnary setObject: uMTL forKey:MTL];
    [UrlDictionnary setObject: uMEL forKey:MEL];
    [UrlDictionnary setObject: uLPE forKey:LPE];
	
    NSEnumerator *enumerator = [UrlDictionnary keyEnumerator];
	
    for (NSString *key in enumerator){
        if ([key hasPrefix: @"École" ] || [key hasSuffix:@"École"] ||[key hasSuffix: @"école"]) {
            NSLog(@"<Clef: %@ > " @"<Url : %@>",key,[UrlDictionnary objectForKey:key]);
        }
		
    }
}

void AfficheInfoIntrospection()
{
	NSMutableArray * array = [NSMutableArray array];
	
	[array addObject:@"Un objet String"];
	[array addObject: [[NSURL alloc] initWithString:@"https://www.google.ca/"]];
	[array addObject:[NSProcessInfo processInfo]];
	[array addObject:[NSDictionary dictionary] ];
	
	
	for (NSObject *myObject in array)
	{
		NSLog(@"Classe: '%@'", [myObject className]);
		if([myObject isMemberOfClass: [NSString class]])
			NSLog(@"Est membre de NSString: OUI");
		else
			NSLog(@"Est membre de NSString: NON");

		
		if([myObject isKindOfClass: [NSString class]])
			NSLog(@"Une sorte de NSString: OUI");
		else
			NSLog(@"Une sorte de NSString: NON");
		
		SEL sel = @selector(lowercaseString);
		if([myObject respondsToSelector: sel])
		{
			NSLog(@"Respond a lowercaseString: OUI");
			NSLog(@"lowercaseString is: '%@'", [myObject performSelector:sel withObject:myObject]);
		}
		else
			NSLog(@"Respond a lowercaseString: NON");
		
		
		NSLog(@"=================================");
	}
	
	// Code ici
}

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
	
	AfficheInfoPath(); // Fonctionnalité 1
	AfficheInfoProcessus(); // Fonctionnalité 2
	AfficheInfoSignets(); // Fonctionnalité 3
	AfficheInfoIntrospection(); // Fonctionnalité 4

    // insert code here...
    NSLog(@"Fin");
    [pool drain];
    return 0;
}
